package com.wjy.consumer.controller;

import com.wjy.api.dto.UserAddDTO;
import com.wjy.api.dto.UserDTO;
import com.wjy.api.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class DubboConsumerController {
    @DubboReference(version = "1.0.0",protocol = "dubbo",validation = "true")
    private UserService userService;

    @GetMapping("/test")
    public String test() {
        return "测试";
    }

    @GetMapping("/get")
    public UserDTO get(@RequestParam("id") Integer id) {
        return userService.get(id);
    }

    @PostMapping("/add")
    public Integer add(UserAddDTO addDTO) {
        return userService.add(addDTO);
    }
}
